/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 25
 * Time: 14:07
 */
//牛客 二维数组中的查找
public class Solution3 {
    public boolean Find (int target, int[][] array) {
        if(array.length == 0) return false;
        if(array[0].length == 0) return false;
        int i = array.length - 1;
        int j = 0;
        while(i >= 0 && j <= array[0].length - 1) {
            if(target > array[i][j]) {
                j++;
            }else if(target < array[i][j]) {
                i--;
            }else {
                return true;
            }
        }
        return false;
    }
}
